package com.jagochan.module.business.controller;

import com.jagochan.common.result.ResultUtils;
import com.jagochan.common.result.ResultVo;
import com.jagochan.module.business.pojo.req.PhoneSendCodeReq;
import com.jagochan.module.business.service.UserService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


@Tag(name = "用户")
@RequiredArgsConstructor
@RequestMapping("/community/user")
@RestController
public class UserController {

    private final UserService userService;

    @Operation(summary = "发送验证码")
    @PostMapping("/send-code")
    public ResultVo<Boolean> sendMessage(@RequestBody @Valid PhoneSendCodeReq phoneSendCodeReq) {
        String code = userService.sendCode(phoneSendCodeReq.getPhone());
        return ResultUtils.success("★测试环境★验证码是：【" + code + "】", true);
    }

}